package com.gylang.easy.exception;


import com.gylang.api.BaseCode;
import com.gylang.api.BaseResultCode;
import lombok.Getter;
import lombok.Setter;

/**
 * @author gylang,
 * date 2020/4/14,
 * @version 1.0
 */

@Getter
@Setter
public class BizException extends RuntimeException implements BaseCode {


	private String code;

	private String msg;


	public BizException() {
		super(BaseResultCode.PARAMS_ERROR.getMsg());
		this.code = BaseResultCode.PARAMS_ERROR.getCode();
		this.msg = BaseResultCode.PARAMS_ERROR.getMsg();
	}

	public BizException(BaseCode baseCode) {
		super(baseCode.getMsg());
		this.code = baseCode.getCode();
		this.msg = baseCode.getMsg();
	}

	public BizException(String code, String msg) {
		super(msg);
		this.code = code;
		this.msg = msg;
	}

	public BizException(String msg) {
		super(msg);
		this.code = BaseResultCode.PARAMS_ERROR.getCode();
		this.msg = msg;
	}

	public BizException(Exception e) {
		super(e);
		this.code = BaseResultCode.PARAMS_ERROR.getCode();
		this.msg = e.getMessage();
	}

}
